﻿using Fuse8.ContentManagementFramework.BizFacade.Services;
using Fuse8.ContentManagementFramework.Domain;
using Fuse8.ContentManagementFramework.Domain.Special;
using Fuse8.DomainFramework.BusinessService;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;

namespace Fuse8.ContentManagementFramework.Administration.Models
{
    [Serializable]
    public class CmsAdminSiteModel
    {
        public int Id { get; set; }

        public int SiteGroupId { get; set; }

        [Required(ErrorMessage = "Please enter site name")]
        public string SiteName { get; set; }

        [Required(ErrorMessage = "Please enter website url")]
        public string SiteUrl { get; set; }

        public IList<int> SelectedUsers { get; set; }

        public int SiteToCloneId { get; set; }

        public bool IsCloneMode { get; set; }

        public IEnumerable<CmsUser> AssignedUsers { get; set; }

        public IEnumerable<CmsUser> AllUsers { get; set; }

        public IEnumerable<CmsSiteGroup> SiteGroups
        {
            get
            {
                var siteGroupService = new BusinessServiceFacade<CmsSiteGroup, int>();
                return siteGroupService.FindAll();
            }
        }

        public IEnumerable<CmsSite> AllSites
        {
            get
            {
                var siteService = new CmsSiteService();
                var sites = siteService.FindAll();
                return sites;
            }
        }

        public CmsSiteProperties ConvertToSiteProperties()
        {
            return new CmsSiteProperties
                       {
                           SiteUrl = this.SiteUrl
                       };
        }
    }
}